One or more aspects relate, in general, to processing within a computing environment, and in particular, to processing associated with database systems of a computing environment.
Database systems allow the creation of user-defined functions (UDFs) that encapsulate application logic and can be invoked from SQL (Structured Query Language) statements. UDFs can be developed in a general purpose programming language, like C or Java, or they can be coded natively in SQL Procedural Language (SQL PL). Each invocation of a UDF results in a call overhead due to context switching.
There are scalar UDFs, which return a single value, and table UDFs, which return a result set. UDFs may or may not issue SQL statements themselves to compute the result. Application developers choose UDFs to push down application logic to the database tier, which can speed up performance and encapsulate common logic. It also enables the aggregation of data records directly in the database, if the data exists in different units and requires some kind of normalization first, e.g. same physical unit, same financial currency, same date intervals, etc.
Database systems today are capable of statically optimizing the execution of queries containing UDFs by inlining them or by caching result sets. However, this is a static decision that is set when a query referencing the UDF is prepared by the optimizer, and hence, only optimizes the processing for certain sets of workloads, which does not help other workloads.